import { delCache } from "#server/utils/context"; import { deleteCard, getCardById } from "../../service/card"; export default defineWrappedResponseHandler(async (event) => { const idParam = getRouterParam(event, "id"); if (!idParam) return R.throwError(400, "缺少卡片 ID", null); const id = parseInt(idParam); if (isNaN(id)) return R.throwError(400, "卡片 ID 格式不正确", null); const existing = await getCardById(id); if (!existing) return R.throwError(404, "卡片不存在", null); await deleteCard(id); await delCache(`card:${id}`); await delCache("categories:tree"); return R.success(null); });